Uploading Files
The REST API endpoint POST /api/v2/document may be used to:
-
Upload files to Assetic.
-
Create a URL reference link
For an overview of documents in Assetic refer to the following article titled Documents
NOTE The file to be uploaded needs to be base64 encoded string for upload.
The response is the document representation, including the 'Id' property which has the generated guid of the document.
Using the API
The parameters for this endpoint are listed in the following table:
Parameter | Description | Type | Mandatory |
ExpiryDate | Date the document expires | Datetime | No |
DocumentGroup | High level classification of file content/relevance. Obtain options via API endpoint GET /api/v2/document/group | Integer | No |
DocumentCategory | Site specific categorisation of file content/relevance. Obtain options via API endpoint GET /api/v2/document/category | Integer | No |
DocumentSubCategory | Site specific subcategorisation of file content/relevance. Obtain options via API endpoint GET /api/v2/document/category/{id}/subcategory where {id} is the DocCategoryId | Integer | No |
ParentType |
Optional. Required if linking the document to an Assetic record (in combination with ParentIdentifier or ParentId parameter) One of: 'None', 'All', 'ComplexAsset', 'WorkRequest', 'L2Assessment', 'DataExchange', 'GroupAssets'(functional location), 'Reports', 'WorkOrder', 'JobPlan', 'SearchProfle', 'FinancialYearAccountingReports', 'FinancialPeriodAccountingReports', 'AsmtProject', 'AsmtTask', 'AsmtFormResult', 'WorkOrder2', 'ValuationReport', 'RevaluationReport', 'BulkProcess', 'DataExchangeProfile', 'BackgroundWorkerLog', 'TransactionBatchExportJournals', 'FinancialYearFairValueJournalReport', 'FinancialPeriodFairValueJournalReport', 'FinancialYearHistoricalJournalReport', 'FinancialPeriodHistoriucalJournalReport', 'ReconciliationHistoricalReport', 'ReconciliationFairvalueReport', 'ServiceBusWorkerErrorDocument', 'BasicReconciliationHistoricalReport', 'BasicReconciliationFairvalueReport', 'Predictor', 'JobPlan2' |
String | Conditional |
ParentId | The unique identifier of an Assetic record (i.e. asset, work order, assessment) to link the file to. Use in conjunction with ParentType if ParentIdentifier is not set | GUID | Conditional |
ParentIdentifier | The user friendly ID of the Assetic record (e.g Asset ID, Work Order ID) | String | Conditional |
IsKeyPhoto | Set as the key photo (if an image file) | Boolean | No (default is False) |
FileProperty | An array of objects containing the files to be loaded. Required if not creating a URL link | Array | Conditional |
DocumentLink | A URL. Must be preceded with the protocol such as HTTP,HTTPS,MAILTO etc. Required if FileProperty is null | String | Conditional |
Label | A reference label for the DocumentLink. Required if DocumentLink is specified, but not required if FileProperty is specified | String(256) | Conditional |
Description | A free text field describing the document content | String(256) | No |
ExternalId | A reference to an external identifier | String(200) | No |
Conditional Parameters
-
If ParentId is defined ParentIdentifier should be NULL and ParentType should be defined. ParentType must match the module that the ParentId is associated with.
-
Conversely if ParentIdentifier is defined then ParentId should be NULL and ParentType should be defined. ParentType must match the module that the ParentId is associated with.
-
Must specify one of FileProperty or DocumentLink
-
If DocumentLink is specified, Label must also be specified
File Property
The following table lists the parameters for the FileProperty object:
Parameter | Decription | Type | Mandatory |
Name | The name of the file (minus file extension). This will be the label of the document in Assetic | String | Yes |
mimetype | Mime type - file format identifier | String | Yes |
filecontent | The file as a base64 encoded string (max file size: 500MB) | String | Yes |
fileSize | The size of the file. Used for displaying size in Assetic | Float | No |
The response to the request is an array, the array size corresponding with the number of documents uploaded.
Sample Payload - File Upload
The following sample uploads a text file called 'ExampleFile.txt'. The contents of the file is a single line of text 'Assetic' (base64 encoded). The file will be linked to an asset (Asset ID=RD123), and has an Expiry Date specified.
{ "ParentType": "ComplexAsset", "DocumentGroup": 1, "DocumentSubCategory": 2, "DocumentCategory": 3, "FileProperty": [ { "Name": "ExampleFile", "FileSize": 7, "mimetype": "txt", "filecontent": "QXNzZXRpYw==" } ], "ParentIdentifier": "RD123", "ExpiryDate": "2016-06-02T23:45:29.559Z" }
Sample Payload - Document Link creation
The following sample creates a link to a pdf document in a document server (Document or Content Management System) for the asset "RD123".
{ "Label": "Construction Plan", "DocumentLink": "http://documentserver/rd123/construction.pdf", "ParentIdentifier": "RD123", "ParentType": "ComplexAsset", "DocumentGroup": 1, "DocumentSubCategory": 2, "DocumentCategory": 3 }
An example of how to perform a document upload via script is demonstrated in this article in the Integration SDK section.